<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="../vue/element-plus/index.css" />
    <style>
      .mybtn {
        /* color: red; */
        height: 30px;
      }
      .primary {
        background-color: rgba(28, 145, 247, 0.725);
      }
      .warn {
        background-color: rgba(255, 153, 0, 0.725);
      }
      .danger {
        background-color: rgba(255, 0, 0, 0.725);
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- 组件 -->
      <el-button type="primary">按钮</el-button>
      <my-button type="primary" text="确认"> </my-button>
      <my-button type="warn" text="警告"></my-button>
      <my-button type="danger" text="删除"></my-button>
      <my-button type="abc" :text="title" inner-html="test"></my-button>
    </div>
    <script src="../vue/vue.global.js"></script>
    <script src="../vue/element-plus/index.js"></script>
    <script>
      const app = Vue.createApp({
        data() {
          return {
            title: "",
          };
        },
      });
      app.use(ElementPlus);

      // 自定义组件, 全局注册: app.component在整个应用中都可以使用
      app.component("my-button", {
        props: {
          type: {
            type: String, // 类型
            validator(value) {
              // 校验
              return ["primary", "warn", "danger"].includes(value);
            },
            default: "primary", // 默认值
          },
          text: {
            type: String, // 类型
            required: true, // 必须传递
            default: "按钮", // 默认值
          },
          msg: {
            type: Array,
            default() {
              return [];
            },
          },
          innerHtml: {
            type: String,
          },
        },
        // 模板
        template: `<button :class='type' @click='clickHanlder'>{{ text }}, {{ innerHtml }}</button>`,
      });
      app.mount("#app");
    </script>
  </body>
</html>
